package com.ruoyi.business.service.impl;

import java.util.List;

import com.ruoyi.business.domain.bo.UserBo;
import com.ruoyi.system.domain.vo.InnerObjVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.UserMapper;
import com.ruoyi.business.domain.User;
import com.ruoyi.business.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * 普通用户Service业务层处理
 * 
 * @author 吴倩芸
 * @date 2023-03-04
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService
{
    @Autowired
    private UserMapper userMapper;

    /**
     * 查询普通用户
     * 
     * @param id 普通用户主键
     * @return 普通用户
     */
    @Override
    public User selectUserById(Long id)
    {
        return userMapper.selectUserById(id);
    }

    /**
     * 查询普通用户列表
     * 
     * @param user 普通用户
     * @return 普通用户
     */
    @Override
    public List<User> selectUserList(User user)
    {
        return userMapper.selectUserList(user);
    }

    /**
     * 新增普通用户
     * 
     * @param bo 普通用户
     * @return 结果
     */
    @Override
    public int insertUser(UserBo bo)
    {
        User user = new User();
        BeanUtils.copyProperties(bo, user);
        user.setSysUserId(bo.getId());
        return userMapper.insertUser(user);
    }

    /**
     * 修改普通用户
     * 
     * @param user 普通用户
     * @return 结果
     */
    @Override
    public int updateUser(User user)
    {
        user.setSysUserId(null);
        return userMapper.updateUser(user);
    }

    /**
     * 批量删除普通用户
     * 
     * @param ids 需要删除的普通用户主键
     * @return 结果
     */
    @Override
    public int deleteUserByIds(Long[] ids)
    {
        return userMapper.deleteUserByIds(ids);
    }

    /**
     * 删除普通用户信息
     * 
     * @param id 普通用户主键
     * @return 结果
     */
    @Override
    public int deleteUserById(Long id)
    {
        return userMapper.deleteUserById(id);
    }

    @Override
    public List<InnerObjVo> queryRefUserInnerObj(String name) {
        List<InnerObjVo> list = userMapper.queryRefUserInnerObj(name);
        return list;
    }
}
